<?php

require_once("models/ISearchable.php");

class AgeSearch implements ISearchable{
	
    private $m_age ;
    private $m_param ;
    
    const GREATER = 2 ;
    const SMALLER = 1 ;
    const EQUAL = 0 ;
    
    
    public function __construct($a_age, $a_param) {
        $this->m_age = $a_age ;
        $this->m_param = $a_param ;
    }

	public function isSelected(MemberClass $a_member){
        $year = substr($a_member->ssn,0,2) ;
		$month = substr($a_member->ssn,2,2) ;
		$day = substr($a_member->ssn,4,2) ;
		
        switch($this->m_param) {
            case self::GREATER :
                if ($year > $this->m_age) {
                    return TRUE ;
                }
                break ;
            case self::SMALLER :   
                if ($year < $this->m_age){
                    return TRUE ;
                }
                break ;
            default :
                if ($year == $this->m_age){
                    return TRUE ;
                }
        }
        return FALSE ;

	}

	
}
